#coding=utf-8

from sdsource.web.utility import get_file
from sdsource.web.sina.suggest import get_market
import datetime

today = datetime.date.today().isoformat()

#url = "http://image.sinajs.cn/newchart/%s/n/%s.gif" % (img_type,stock_code)
#http://image.sinajs.cn/newchart/daily/n/sh600000.gif

def download_kimg(code, img_type='daily', fpath=None):
    
    if not fpath:
        fpath = '/home/jay/kimg/%s_%s.gif'%(code,today)
         
    mcode = get_market(code) + code
    url = "http://image.sinajs.cn/newchart/%s/n/%s.gif" % (img_type, mcode)
    #print url, fpath
    get_file(url, fpath)

